<template>
    <div class="layout">
        <Layout>
            <Sider ref="side1" hide-trigger collapsible :collapsed-width="78" v-model="isCollapsed">
                <Menu active-name="/dashboard"  width="auto" 
                :class="menuitemClasses" 
                router>
                    <MenuItem name="/dashboard" to="/dashboard">
                        <Icon type="ios-navigate"></Icon>
                        <span>Dashboard</span>
                    </MenuItem>
                    <MenuItem name="/sys/menu" to="/sys/menu">
                        <Icon type="ios-search"></Icon>
                        <span>菜单配置</span>
                    </MenuItem>
                    <MenuItem name="/sys/user" to="/sys/user">
                        <Icon type="ios-search"></Icon>
                        <span>用户管理</span>
                    </MenuItem>
                </Menu>
            </Sider>
            <Layout>
                <Header :style="{padding: 0}" class="layout-header-bar">
                    <Icon @click.native="collapsedSider" :class="rotateIcon" :style="{margin: '20px',cursor: 'pointer'}" type="md-menu" size="24"></Icon>
                    <Icon @click.native="openDrawer" type="md-more" size="24" style="float:right;cursor:pointer;margin:20px 10px;"/>
                    
                    
                     <Dropdown style="float:right;margin:16px 10px;cursor:pointer;">
                        <div>
                            <Avatar style="background-color: #87d068;margin-right:10px;" icon="ios-person" />
                            Acmen
                            <Icon type="ios-arrow-down"></Icon>
                        </div>
                        <DropdownMenu slot="list">
                            <DropdownItem>个人信息</DropdownItem>
                            <DropdownItem>设置</DropdownItem>
                            <DropdownItem>退出</DropdownItem>
                        </DropdownMenu>
                    </Dropdown>
                    <div style="float:right;line-height:64px;">
                        
                    </div>
                </Header>
                <Content :style="{margin: '10px', background: '#fff', height: '100%'}">
                    <router-view/>
                </Content>
            </Layout>
        </Layout>
        <Drawer title="Basic Drawer" :closable="false" v-model="drawer">
            <p>Some contents...</p>
            <p>Some contents...</p>
            <p>Some contents...</p>
        </Drawer>
    </div>
</template>
<script>
    export default {
        data () {
            return {
                isCollapsed: false,
                drawer: false
            }
        },
        computed: {
            rotateIcon () {
                return [
                    'menu-icon',
                    this.isCollapsed ? 'rotate-icon' : ''
                ];
            },
            menuitemClasses () {
                return [
                    'menu-item',
                    this.isCollapsed ? 'collapsed-menu' : ''
                ]
            }
        },
        mounted () {
          this.$router.push({path: '/dashboard'})
        },
        methods: {
            collapsedSider () {
                this.$refs.side1.toggleCollapse();
            },
            openDrawer () {
                this.drawer = true
            }
        }
    }
</script>

<style scoped>
    .layout{
        border: 1px solid #d7dde4;
        background: #f5f7f9;
        position: relative;
        height: 100%;
        overflow: hidden;
    }
    .ivu-layout{
      height: 100%;
    }
    .layout-header-bar{
        background: #fff;
        box-shadow: 0 1px 1px rgba(0,0,0,.1);
    }
    .layout-logo-left{
        width: 90%;
        height: 30px;
        background: #5b6270;
        border-radius: 3px;
        margin: 15px auto;
    }
    .ivu-layout-header{
        line-height: normal;
    }
    .menu-icon{
        transition: all .3s;
    }
    .rotate-icon{
        transform: rotate(-90deg);
    }
    .menu-item span{
        display: inline-block;
        overflow: hidden;
        width: 69px;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: bottom;
        transition: width .2s ease .2s;
    }
    .menu-item i{
        transform: translateX(0px);
        transition: font-size .2s ease, transform .2s ease;
        vertical-align: middle;
        font-size: 16px;
    }
    .collapsed-menu span{
        width: 0px;
        transition: width .2s ease;
    }
    .collapsed-menu i{
        transform: translateX(5px);
        transition: font-size .2s ease .2s, transform .2s ease .2s;
        vertical-align: middle;
        font-size: 22px;
    }
    .ivu-menu{
      height: 100%;
    }
</style>

